﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DHQGHN.DAL.Common;
using DHQGHN.DAL.DAO.Admin;
using DHQGHN.DAL.Models.Admin;
namespace DHQGHN.DAL.BO.Admin
{
   public class ResidentStatusBO:BaseBO
    {
       #region field in database
        public const string FIELD_RESIDENT_STATUS_ID = "RESIDENT_STATUS_ID";
        public const string FIELD_CODE = "CODE";
        public const string FIELD_NAME = "NAME";
        public const string FIELD_DESCRIPTIONS = "DESCRIPTIONS";
        public const string FIELD_DELETED = "DELETED";
        #endregion
        public const string FIELD_RECORD_COUNT = "RecordCount";

        private String _connectionString;

        public ResidentStatusBO(string connString)
        {
            this._connectionString = connString;
        }

        public ResidentStatusBO()
        {
            this._connectionString = Common.ConnectionUtil.TKTHDS_METADATA_CONNECTION_STRING;

        }

        public ResidentStatusDAO _ResidentStatusDAO;
        public ResidentStatusDAO CreateSQLDAO()
        {
            return new ResidentStatusDAO(_connectionString, DEFAULT_MAPPER_TYPE);
        }

        public ResidentStatusBO(string _connectionString, Type DEFAULT_MAPPER_TYPE)
        {
            // TODO: Complete member initialization

            this.DEFAULT_MAPPER_TYPE = DEFAULT_MAPPER_TYPE;
        }


        public DataPage<ResidentStatusModel> GetDynamicListPaging(ResidentStatusModel aModel, int pageSize, int pageIndex, bool compareEqual)
        {
            try
            {
                _ResidentStatusDAO = CreateSQLDAO();
                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {ResidentStatusModel.FIELD_RESIDENT_STATUS_ID,FIELD_RESIDENT_STATUS_ID},
                    {ResidentStatusModel.FIELD_NAME,FIELD_NAME},
                    {ResidentStatusModel.FIELD_CODE,FIELD_CODE},  
                    {ResidentStatusModel.FIELD_DESCRIPTIONS,FIELD_DESCRIPTIONS},
                    {ResidentStatusModel.FIELD_DELETED,FIELD_DELETED},
                    {ResidentStatusModel.FIELD_RECORD_COUNT, FIELD_RECORD_COUNT}
                };
                return _ResidentStatusDAO.GetDynamicListPaging(aModel, pageSize, pageIndex, mapDictionary, compareEqual);
            }
            catch (Exception)
            {
                throw;
            }
        }
        public ResidentStatusModel GetResidentStatusId(string id)
        {
            try
            {
                _ResidentStatusDAO = CreateSQLDAO();

                Dictionary<String, String> mapDictionary = new Dictionary<string, string>()
                {
                    {ResidentStatusModel.FIELD_RESIDENT_STATUS_ID,FIELD_RESIDENT_STATUS_ID},
                    {ResidentStatusModel.FIELD_NAME,FIELD_NAME},
                    {ResidentStatusModel.FIELD_CODE,FIELD_CODE},  
                    {ResidentStatusModel.FIELD_DESCRIPTIONS,FIELD_DESCRIPTIONS},  
                    {ResidentStatusModel.FIELD_DELETED,FIELD_DELETED},
                    {ResidentStatusModel.FIELD_RECORD_COUNT, FIELD_RECORD_COUNT}
                };

                return _ResidentStatusDAO.GetById(id, mapDictionary);
            }
            catch (Exception)
            {
                throw;
            }
        }

        public bool createOrUpdateResidentStatus(ResidentStatusModel model)
        {
            try
            {
                _ResidentStatusDAO = CreateSQLDAO();
                return _ResidentStatusDAO.createOrUpdateResidentStatus(model);
            }
            catch (Exception e)
            {
                return false;
            }
        }

        public bool deleteResidentStatus(string[] ID)
        {
            try
            {
                _ResidentStatusDAO = CreateSQLDAO();
                return _ResidentStatusDAO.deleteResidentStatus(ID);
            }
            catch (Exception e)
            {
                return false;
            }
        }
    }
}